package com.jbookshelf.dal.providers;

import org.hibernate.SessionFactory;
import org.hibernate.classic.Session;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.jbookshelf.dal.entities.BooksGenres;

@Repository
@Scope(value="request", proxyMode=ScopedProxyMode.INTERFACES)
public class BooksGenresProviderImpl implements BooksGenresProvider {

	@Autowired
	SessionFactory sessionFactory;
	
	@Override
	@Transactional(propagation=Propagation.REQUIRED, rollbackFor=Exception.class)
	public void saveBooksGenres(BooksGenres newBG) {
		Session s = sessionFactory.getCurrentSession();
        s.save(newBG);
	}

}
